$(document).ready(function() {	
	var strDefault = $('#pdefault').val();
	$("#frmComment").validate({
		errorClass		: 'errorMessage',
		errorElement	: 'span',
		onfocusout		: false,
		onkeyup			: false,
		rules: {				
			pcontent: {
				requiredContent		: true,
				minlengthContent	: true
			}
		},
		messages: {	
			pcontent: {
				requiredContent		: content_required,
				minlengthContent	: content_minlength
			}
		},
		errorPlacement: function(label, element) {	
			var id = element.attr('id');	
			label.insertAfter($('#' + id));			
		},
		submitHandler: function(form) {	
			$('#formCmt').hide();
			$('#loading').show();
			var strContent		= encodeURIComponent($('#pcontent').val());	
			var intOfflineId 	= $('#pofflineid').val();
			$.getJSON(				
				HOST_VFRIEND + 'comment/offcmtsend?content='+strContent+'&offlineid='+intOfflineId+'&callback=?',		
				function(response) {					
					if(response['error'] == 0) {						
						showUIMessage(response['msg']);
						$('#sComment').html(response['data']);						
						//$('#sTotal').html(response['total']);
					} else {
						alert(response['msg']);
					}
					$('#loading').hide();
					$('#formCmt').show();
					$('#pcontent').val(strDefault);
					$('#pcontent').css("min-height","18px");
					$('#pcontent').css("height","18px");
					$("textarea#pcontent").css("color","#999");
					$("#emo_pcontent").hide();
				}
			);
		}
	});
	$.validator.addMethod('requiredContent',function(){
		var strContent	= stripTags($('#pcontent').val());		
		if(strContent == '' || strContent.toLowerCase() == strDefault.toLowerCase())
			return false;		
		return true;												 
	});
	$.validator.addMethod('minlengthContent',function(){
		var strContent	= stripTags($('#pcontent').val());			
		if(strContent != '' && strContent.toLowerCase() != strDefault.toLowerCase() && strContent.length < 2)
			return false;		
		return true;												 
	});
});
inviteOff = function(intOfflineId) {
	$.getJSON(				
		HOST_VFRIEND + 'ajax/uioffinvite?offlineid='+intOfflineId+'&callback=?',		
		function(response) {					
			var msg	= response['msg'];
			if(response['error'] == 0) {				
				$.blockUI({
					message: msg, 
					css: { 
						textAlgin:'left',
						background:'none',
						border: 'none',
						width:'400px', 
						top: (($(window).height()-400)/2) + 'px', 
						left:(($(window).width()-400)/2) + 'px',
						cursor: 'default',
						zIndex: '10001'
					},
					overlayCSS: {
						cursor: 'default',
						zIndex: '10000'
					}
				});
				if($('#scrollPane') != undefined) {
					$('#scrollPane').jScrollPane();	
				}
			} else {
				alert(msg);
			}
		}
	);
}
cancelOff = function(intType,intOfflineId) {
	$.getJSON(				
		HOST_VFRIEND + 'ajax/uioffcancel?offlineid='+intOfflineId+'&type='+intType+'&callback=?',		
		function(response) {					
			var msg	= response['msg'];
			if(response['error'] == 0) {				
				$.blockUI({
					message: msg, 
					css: { 
						textAlgin:'left',
						background:'none',
						border: 'none',
						width:'300px', 
						top: (($(window).height()-300)/2) + 'px', 
						left:(($(window).width()-300)/2) + 'px',
						cursor: 'default',
						zIndex: '10001'
					},
					overlayCSS: {
						cursor: 'default',
						zIndex: '10000'
					}
				});
			} else {
				alert(msg);
			}
		}
	);
}
denyOff = function(intType,intOfflineId,intOjoinId,strUserId) {
	$.getJSON(				
		HOST_VFRIEND + 'ajax/uioffdeni?offlineid='+intOfflineId+'&type='+intType+'&ojoinid='+intOjoinId+'&uid='+strUserId+'&callback=?',		
		function(response) {					
			var msg	= response['msg'];
			if(response['error'] == 0) {				
				$.blockUI({
					message: msg, 
					css: { 
						textAlgin:'left',
						background:'none',
						border: 'none',
						width:'300px', 
						top: (($(window).height()-300)/2) + 'px', 
						left:(($(window).width()-300)/2) + 'px',
						cursor: 'default',
						zIndex: '10001'
					},
					overlayCSS: {
						cursor: 'default',
						zIndex: '10000'
					}
				});
			} else {
				alert(msg);
			}
		}
	);
}
function deleteCmt(intOfflineId,intVal,intPage) {	
	if(confirm(confirm_delete) == true) {		
		$.getJSON(				
			HOST_VFRIEND + 'comment/offcmtsend?act=1&offlineid='+intOfflineId+'&ocommentid='+intVal+'&page='+intPage+'&callback=?',		
			function(response) {					
				if(response['error'] == 0) {						
					showUIMessage(response['msg']);
					$('#sComment').html(response['data']);				
				} else {
					alert(response['msg']);
				}
			}
		);
	} 
}
function likeCmt(intOfflineId, intVal) {	
	$.getJSON(				
		HOST_VFRIEND + 'comment/offcmtsend?act=2&offlineid='+intOfflineId+'&ocommentid='+intVal+'&callback=?',		
		function(response) {					
			if(response['error'] == 0) {						
				showUIMessage(response['msg']);
				$('#lcmt' + intVal).html(response['like']);
			} else {
				alert(response['msg']);
			}
		}
	);
}
onMouseOverForCmt = function(intId) {
	$('#rowCmt' + intId).show();
}
onMouseOutForCmt = function(intId) {
	$('#rowCmt' + intId).hide();
}
onMouseOverForOjoin = function(intId) {
	$('#rowOjoin' + intId).show();
}
onMouseOutForOjoin = function(intId) {
	$('#rowOjoin' + intId).hide();
}